package com.ctcemti.mdm.project.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.ctcemti.mdm.project.sys.entity.formdata.BaseReq;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 错误日志对象 t_sys_error_log
 * 
 * @author 
 * @date Tue Nov 12 08:29:33 CST 2019
 */
@Data
@ApiModel("错误日志对象")
@JsonIgnoreProperties(value={"handler"})//是json序列化时忽略bean中的一些属性序列化和反序列化时抛出的异常.
public class ErrorLog extends BaseReq implements Comparable<ErrorLog>
{
    private static final long serialVersionUID = 1L;


    /**
    * id主键
    */
    @Id
    @ApiModelProperty(value = "id主键")
    private Integer id;
    /**
    * 错误编码
    */
    @ApiModelProperty(value = "错误编码")
    @Excel(name="错误编码")
    private String errorCode;
    /**
    * 模块id
    */
    @ApiModelProperty(value = "模块id")
    private String moduleId;
    /**
    * 错误信息
    */
    @ApiModelProperty(value = "错误信息")
    @Excel(name="错误信息")
    private String errorContent;
    /**
    * 操作人
    */
    @ApiModelProperty(value = "操作人")
    @Excel(name="操作人")
    private String operator;
    /**
    * 操作时间
    */
    @ApiModelProperty(value = "操作时间")
    @Excel(name="操作时间",databaseFormat="yyyy-MM-dd HH:mm:ss")
    private Date operateTime;


    @Transient
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private int rowNum;

    @Transient
    @Excel(name = "错误提示")
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private String errorMsg;

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("errorCode", getErrorCode())
            .append("moduleId", getModuleId())
            .append("errorContent", getErrorContent())
            .append("operator", getOperator())
            .append("operateTime", getOperateTime())
            .toString();
    }

    @Override
    public int compareTo(ErrorLog errorLog) {           //重写Comparable接口的compareTo方法，
         return this.rowNum - errorLog.getRowNum();// 根据行号升序排列，降序修改相减顺序即可
    }

}
